# _*_ coding:utf-8 _*_
# @File  : configs.py
# @Time  : 2020-08-31 8:26
# @Author: zizle

""" 配置文件 """
import os
import time
import logging

APP_DIR = os.path.dirname(os.path.abspath(__file__))  # 项目根路径
TOKEN_EXPIRES = 345600  # 4天
ADMIN_FLAG = 'backendAdmin'  # 后台用户的access标记
WEB_HOST = 'http://127.0.0.1:8000/static/'
FILE_STORAGE = "D:/FILE_STORAGE/"                                                       # 项目文件路径
STATIC_FILE_HOST = 'http://127.0.0.1:8000/static/'  # https://210.13.218.130:9000/fileStorage/
WECHAT_FILE_PATH = "D:/WeChatFiles/WeChat Files/wxid_ebc8cjnovw1f22/FileStorage/File/"  # 微信自动保存的文件路径

SECRET_KEY = "cj3gnb1k2xzfq*odw5y-vts^+cv+p8suw+(_5#va%f70=tvt5mp"

JWT_EXPIRE_SECONDS = 86400

# 系统邮箱
SYSTEM_EMAIL = "rdyj_fxjc@163.com"
SYSTEM_EMAIL_AUTH = "LCAWXVQEVNEBBIRF"

RUIZHI_MANAGERS = [2, 3, 154]


# # 日志记录
# def logger_handler(app_dir, log_level):
#     # 日志配置
#     log_folder = os.path.join(app_dir, "logs/")
#     if not os.path.exists(log_folder):
#         os.makedirs(log_folder)
#     log_file_name = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '.log'
#     log_file_path = log_folder + os.sep + log_file_name
#
#     handler = logging.FileHandler(log_file_path, encoding='UTF-8')
#     handler.setLevel(log_level)
#     logger_format = logging.Formatter(
#         "%(asctime)s - %(levelname)s - %(message)s - %(pathname)s[line:%(lineno)d]"
#     )
#     handler.setFormatter(logger_format)
#     return handler
#
#
# logger = logging.getLogger()
# logger.setLevel(logging.INFO)
# logger.addHandler(logger_handler(app_dir=APP_DIR, log_level=logging.INFO))

# 数据库配置
DB_CONFIGS = {
    # 瑞智数据库
    "ruizy_db": {
        'host': 'localhost',
        'port': 3306,
        'user': 'root',
        'password': 'mysql',
        'database': 'ruizy_economydb'
    },
    # 新版数据库连接(mysqlclient连接池)
    "fa": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "mysql",
        "database": "futures_assistant"
    },
    # 系统主数据库
    "mysql": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "mysql",
        "database": "futures_assistant"
    },
    # 用户品种数据表数据库(独立原因: 表数据和字段类型不确定)
    "variety_sheet": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "mysql",
        "database": "fa_variety_sheets"
    },
    # 交易所数据数据库(独立原因: 较早开发,可不整合)
    "exchange_lib": {
        "host": "localhost",
        "port": 3306,
        "user": "root",
        "password": "mysql",
        "database": "fa_exchange_lib"
    },
    "redis": {
        "host": "localhost",
        "port": "6379",
        "db": 1
    }
}
